const { override, fixBabelImports, addLessLoader, addWebpackAlias, addBabelPlugins, disableEsLint, addWebpackModuleRule } = require('customize-cra');
const path = require("path");
module.exports = override(
    addWebpackModuleRule(
        {
            test: /\.svg$/,
            loader: "svg-sprite-loader",
            include: path.resolve(__dirname, "./src/icons"), //只处理指定svg的文件(所有使用的svg文件放到该文件夹下)
            options: {
                symbolId: "icon-[name]" //symbolId和use使用的名称对应      <use xlinkHref={"#icon-" + iconClass} />

            }
        },
    ),
    disableEsLint(),
    fixBabelImports('import', {
        libraryName: 'antd-mobile',
        style: 'css',
    }),
    addLessLoader(
        {
            lessOptions: {
                javascriptEnabled: true,
                modifyVars: { '@primary-color': '#1DA57A' },
                localIdentName: '[local]--[hash:base64:5]'
            }
        }),
    addWebpackAlias({
        ["@"]: path.resolve(__dirname, "src"),
    }),
    addBabelPlugins(
        [
            '@babel/plugin-proposal-decorators',
            {
                legacy: true
            }
        ]
    ),
)